<extend name="layout/edit" />

<block name="HEADER">
	<style type="text/css">
		.file-img {
			height: 100%;
			background-position: left;
			background-size: 100% 85%;
			background-repeat: no-repeat;
			cursor: pointer;
		}
		#selectStoreGrid .layui-btn{ display: none; }
	</style>
</block>

<block name="CONTENT">
	<div id="form" padding="" height="" style="" class="xw-form">
		<div class="wrapper" style="height: calc(100% - 42px);">
			<div class="panel-heading" style="line-height: 30px;padding: 10px;padding-bottom: 5px;">
				<control:search id="selectShopsearchs" />
			</div>
			<div class="content" style="height: calc(100% - 45px);padding: 5px;">
				<control:grid id="selectShopGrid" padding="0" height="100%" />
			</div>
		</div>
		<div class="xw-btnRow" style="text-align: right;">
			<button type="button" class="layui-btn layui-btn-normal layui-btn-sm " id="btnSave" onclick="page.save()" ><i class="iconfont" style="line-height: 0;"></i>确认选择</button> 
				<button type="button" class="layui-btn layui-btn-normal layui-btn-sm " id="close" onclick="$.close()"> <i class="iconfont" style="line-height: 0;"></i>关闭 </button>
		</div>
	</div>

</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns) {
			
			ns.init = function(){
				ns.query();
			}
			
			//搜索事件
		    ns.query=function(){
		    	var filter = selectShopsearchs.getData();
		    	if($.getRequest("can_shop_id")){
		    		filter.push({"field":"id","opera":"not in","value":$.getRequest("can_shop_id")});
				}
                selectShopGrid.load( filter );
		    }
			
			
			//选中事件
			ns.save = function() {
				var ids = selectShopGrid.getSelectedColumnValue('id');
                var datas = selectShopGrid.getSelectedRows();
				if(!ids){
					$.toast(0,"请先选择商户！");
					return false;
				}
                if( parent.page && parent.page.selectShopsCallback){
                    if(parent.page.selectShopsCallback(ids,datas) !== false){
                        $.close();
                    }
                }else{
                    $.close();
                }

			}

			return ns;
		}({}));

		$(function() { page.init(); });
	</script>
</block>